<div class="layuimini-container">
    <form id="app-form" class="layui-form layuimini-form">

        <div class="layui-form-item">
            <label class="layui-form-label required">用户头像</label>
            <div class="layui-input-block layuimini-upload">
                <input name="head_img" class="layui-input layui-col-xs6" lay-verify="required" lay-reqtext="请上传用户头像" placeholder="请上传用户头像" value="">
                <div class="layuimini-upload-btn">
                    <span><a class="layui-btn" data-upload="head_img" data-upload-number="one" data-upload-exts="png|jpg|ico|jpeg" data-upload-icon="image"><i class="fa fa-upload"></i> 上传</a></span>
                    <span><a class="layui-btn layui-btn-normal" id="select_head_img" data-upload-select="head_img" data-upload-number="one" data-upload-mimetype="image/*"><i class="fa fa-list"></i> 选择</a></span>
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label required">登录账户</label>
            <div class="layui-input-block">
                <input type="text" name="username" class="layui-input" lay-verify="required" lay-reqtext="请输入登录账户" placeholder="请输入登录账户" value="">
                <tip>填写登录账户。</tip>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">用户手机</label>
            <div class="layui-input-block">
                <input type="text" name="phone" class="layui-input" lay-reqtext="请输入用户手机" placeholder="请输入用户手机" value="" lay-verify="required">
                <tip>填写用户手机。</tip>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">角色权限</label>
            <div class="layui-input-block">
                {foreach auth_list as $key=>$val}
                <input type="radio" name="auth_ids" lay-skin="primary" title="{$val}" value="{$key}" lay-verify="required" lay-filter="testRadio">
                {/foreach}
            </div>
        </div>
<!--        <div class="layui-form-item layui-hide displayauth_ids">-->
<!--            <label class="layui-form-label">关联用户</label>-->
<!--            <div class="layui-input-block">-->
<!--                <input type="text" name="user_ids" class="layui-input selectuser"  placeholder="请点击选择要关联的普通用户" value="" >-->
<!--            </div>-->
<!--        </div>-->
        <div class="layui-form-item layui-hide displayauth_ids" >
            <label class="layui-form-label required" >关联用户</label>
            <div class="layui-input-block">
                <!--                <select name="user_ids"  data-select="{:url('system.admin/selectuser')}" data-fields="id,username" data-value="{$row.user_ids|default=''}" multiple="multiple"  lay-search="" lay-verify="required">-->
                <!--                </select>-->
                <input type="hidden" name="user_ids" class="layui-input"  placeholder="请点击选择要关联的普通用户" value="{$row.user_ids|default=''}" >
                <div id="demo1"></div>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">备注信息</label>
            <div class="layui-input-block">
                <textarea name="remark" class="layui-textarea" placeholder="请输入备注信息"></textarea>
            </div>
        </div>

        <div class="hr-line"></div>
        <div class="layui-form-item text-center">
            <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit onclick="getq()">确认</button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">重置</button>
        </div>

    </form>
</div>
<script src="__STATIC__/plugs/xm-select/dist/xm-select.js"></script>
<script src="/static/plugs/jquery-3.4.1/jquery-3.4.1.min.js"></script>

<script>
    function getq(){

        var dep = xmSelect.get("#demo1",true);
        var val = dep.getValue('valueStr')

        $("[name='user_ids']").val(val);
    }
</script>
<script type="text/javascript">
    //使用ajax发送请求
    $.ajax({
        url:"/admin/system.admin/selectuser?id=0",
        type:"get",
        dataType:"json",
        success:function(data){
            // console.log(data.data);return false;
            var demo1 = xmSelect.render({
                el: '#demo1',
                language: 'zn',
                data:data.data
                // [
                // {name: '张三', value: 1},
                // {name: '李四', value: 2},
                // {name: '王五', value: 3},
                // ]
            });


        },
        error:function(data){
            //alert(22)
            layer.msg(data.msg);
        }
    });

</script>
<script>

    layui.use(['layer', 'form'], function () {
        var form = layui.form;
        //此处即为 radio 的监听事件
        form.on('radio(testRadio)', function (data) {

            if (data.value == 7) {
                // $("#displayauth_ids").css("display", "block");
                $(".displayauth_ids").removeClass('layui-hide'); //
                $(".displayauth_ids").addClass('layui-show'); //

            } else {
                $(".displayauth_ids").addClass('layui-hide'); //
                $(".displayauth_ids").removeClass('layui-show'); //
            }


        });
    });

</script>